package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.DestinationCommend;
import cn.wolfcode.luowowo.article.query.DestinationCommendQuery;
import cn.wolfcode.luowowo.article.service.IDestinationCommendService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("destinationCommend")
public class DestinationCommendController {

    @Reference
    private IDestinationCommendService destinationCommendService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")DestinationCommendQuery qo){
        model.addAttribute("pageInfo", destinationCommendService.query(qo));
        return "destinationCommend/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(DestinationCommend commend) {
        destinationCommendService.saveOrUpdate(commend);
        return AjaxResult.SUCCESS;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id) {
        destinationCommendService.delete(id);
        return AjaxResult.SUCCESS;
    }

    @RequestMapping("/changeStateValue")
    @ResponseBody
    public Object changeStateValue(int state,Long id) {
        destinationCommendService.changeStateValue(id,state);
        return AjaxResult.SUCCESS;
    }
}
